.class final Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;
.super Ljava/lang/Object;
.source "MraidWrappedContentProvider.java"

# interfaces
.implements Lcom/burstly/lib/component/networkcomponent/burstly/html/IWrappedContentProvider;


# static fields
.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final MRAID_BRIDGE_SCRIPT_TAG:Ljava/lang/String; = null

.field private static final MRAID_SCRIPT_TAG:Ljava/lang/String; = null

.field private static final MRAID_TAG_PATTERN:Ljava/util/regex/Pattern; = null

.field private static final TAG:Ljava/lang/String; = "MraidWrappedContentProvider"


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 35
    const-string v1, "<script.*mraid.js.*?/script>"

    invoke-static {v1}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v1

    sput-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_TAG_PATTERN:Ljava/util/regex/Pattern;

    .line 48
    invoke-static {}, Lcom/burstly/lib/constants/UriConstants;->getInstance()Lcom/burstly/lib/constants/UriConstants;

    move-result-object v1

    invoke-virtual {v1}, Lcom/burstly/lib/constants/UriConstants;->getContentRoot()Ljava/lang/String;

    move-result-object v0

    .line 49
    .local v0, contentRoot:Ljava/lang/String;
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "<script type=\"text/javascript\" src=\""

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "/lib/mraid_android_v3.js\"></script>"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    sput-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_SCRIPT_TAG:Ljava/lang/String;

    .line 51
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "<script type=\"text/javascript\" src=\""

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "/lib/mraid_bridge_android_v2.js\"></script>"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    sput-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_BRIDGE_SCRIPT_TAG:Ljava/lang/String;

    .line 62
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v1

    sput-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-void
.end method

.method constructor <init>()V
    .locals 0

    .prologue
    .line 30
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public destroy()V
    .locals 0

    .prologue
    .line 105
    return-void
.end method

.method public prepareWrappedContent(Ljava/lang/String;)Ljava/lang/String;
    .locals 8
    .parameter "wholeHtml"

    .prologue
    const/4 v4, 0x0

    .line 72
    const-string v5, "<html"

    invoke-virtual {p1, v5}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v5

    if-gez v5, :cond_0

    const-string v5, "<HTML"

    invoke-virtual {p1, v5}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v5

    if-ltz v5, :cond_1

    :cond_0
    const/4 v0, 0x1

    .line 73
    .local v0, hasHtmlWrap:Z
    :goto_0
    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3, p1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 74
    .local v3, wholeHtmlBuffer:Ljava/lang/StringBuilder;
    new-instance v2, Ljava/lang/StringBuffer;

    invoke-direct {v2}, Ljava/lang/StringBuffer;-><init>()V

    .line 75
    .local v2, out:Ljava/lang/StringBuffer;
    if-eqz v0, :cond_4

    .line 76
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_TAG_PATTERN:Ljava/util/regex/Pattern;

    invoke-virtual {v5, p1}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v1

    .line 77
    .local v1, matcher:Ljava/util/regex/Matcher;
    invoke-virtual {v1}, Ljava/util/regex/Matcher;->find()Z

    move-result v5

    if-eqz v5, :cond_2

    .line 78
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_BRIDGE_SCRIPT_TAG:Ljava/lang/String;

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_SCRIPT_TAG:Ljava/lang/String;

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v1, v2, v4}, Ljava/util/regex/Matcher;->appendReplacement(Ljava/lang/StringBuffer;Ljava/lang/String;)Ljava/util/regex/Matcher;

    .line 79
    invoke-virtual {v1, v2}, Ljava/util/regex/Matcher;->appendTail(Ljava/lang/StringBuffer;)Ljava/lang/StringBuffer;

    .line 80
    invoke-virtual {v2}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v4

    .line 100
    .end local v1           #matcher:Ljava/util/regex/Matcher;
    :goto_1
    return-object v4

    .end local v0           #hasHtmlWrap:Z
    .end local v2           #out:Ljava/lang/StringBuffer;
    .end local v3           #wholeHtmlBuffer:Ljava/lang/StringBuilder;
    :cond_1
    move v0, v4

    .line 72
    goto :goto_0

    .line 82
    .restart local v0       #hasHtmlWrap:Z
    .restart local v1       #matcher:Ljava/util/regex/Matcher;
    .restart local v2       #out:Ljava/lang/StringBuffer;
    .restart local v3       #wholeHtmlBuffer:Ljava/lang/StringBuilder;
    :cond_2
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v6, "MraidWrappedContentProvider"

    const-string v7, "mraid.js script hasn`t been found in HTML!"

    new-array v4, v4, [Ljava/lang/Object;

    invoke-virtual {v5, v6, v7, v4}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 94
    .end local v1           #matcher:Ljava/util/regex/Matcher;
    :goto_2
    invoke-virtual {v2, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/CharSequence;)Ljava/lang/StringBuffer;

    .line 95
    if-nez v0, :cond_3

    .line 96
    const-string v4, "</div> "

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 97
    const-string v4, "</body> "

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 98
    const-string v4, "</html> "

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 100
    :cond_3
    invoke-virtual {v2}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v4

    goto :goto_1

    .line 84
    :cond_4
    const-string v4, "<html>"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 85
    const-string v4, "<head>"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 86
    const-string v4, "<meta name=\'viewport\' content=\'user-scalable=no initial-scale=1.0\' />"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 87
    const-string v4, "<title>Advertisement</title> "

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 88
    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_BRIDGE_SCRIPT_TAG:Ljava/lang/String;

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 89
    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/html/mraid/MraidWrappedContentProvider;->MRAID_SCRIPT_TAG:Ljava/lang/String;

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 90
    const-string v4, "</head>"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 91
    const-string v4, "<body style=\"margin:0; padding:0; overflow:hidden; background-color:transparent;\">"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    .line 92
    const-string v4, "<div align=\"center\"> "

    invoke-virtual {v2, v4}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    goto :goto_2
.end method
